package com.han.spring.core.custom_bean_nature;
/**
* @author hanpeng
* @version 创建时间：2020年7月7日 下午7:36:07
* @ClassName 类名称
* @Description 类描述
*/

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.DefaultLifecycleProcessor;

public class CustomBeanNatureTest {
	@Test
	public void testCallBackLifecycle() {
		//custom_bean_nature.xml
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("custom_bean_nature.xml");
		//DefaultLifecycleProcessor lifecycleProcessor
		LifecycleCallbackBean exampleBean = context.getBean("lifecycleCallbackBean", LifecycleCallbackBean.class);
		System.out.println(exampleBean.getName());
		DefaultLifecycleProcessor defaultLifecycleProcessor = context.getBean("lifecycleProcessor", DefaultLifecycleProcessor.class);
		context.registerShutdownHook();
		((AbstractApplicationContext) context).close();
	}
}	
